<template>
<a-card :bordered="false">
    <div class="table-operator">
        <a-button shape="round" size="small" type="primary" icon="plus" @click="handleEdit({dictType:'2',systemNo:defaultSettings.systemNo},'dictForm','新增')">添加</a-button>
    </div>
    <LTable
        ref="dictTable"
        size="small"
        rowKey="keyId"
        :columns="columns"
        :formAttributes="formAttributes"
        :initQuery="initQuery"
        :initOrder="initOrder"
        axiosUrl="/SysDictController/page"
        :showPagination="true"
        :showQueryForm="true"
        :isAutoLoad="true"
      >
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'dictForm',record.dictName)">编辑</a>
          <a-divider type="vertical"/>
          <a @click="handleEdit(record,'dictItemForm',record.dictName)"><a-icon type="setting" />字典配置</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete({keyId:record.keyId,dictCode:record.dictCode},'/SysDictController/del','dictTable')">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </LTable>
      <dictForm ref="dictForm" @close="refresh('dictTable')" @ok="refresh('dictTable')"></dictForm> 
      <dictItemForm ref="dictItemForm" ></dictItemForm> 
</a-card>
    
</template>

<script>
import LTable from '@/components/lt/LTable'
import {SysMixin} from '@/mixins/SysMixin'
import dictForm from './dictForm'
import dictItemForm from './dictItemForm'
import defaultSettings from '@/config/defaultSettings'

export default {
    name:'dictList',
    components: {
        LTable,dictForm,dictItemForm
    },
    mixins:[SysMixin],
    data(){
        return{
            defaultSettings,
            dictTableSelectedRowKeys:[],
            formAttributes:[
                {field:'dictName',label:'字典名称',component:'input',condition:'like'},
                {field:'dictCode',label:'字典编号',component:'input',condition:'like'},
               
            ],
            initQuery:[{field:'dictType',val:'2'},{field:'systemNo',val:defaultSettings.systemNo}],
            initOrder:[{field:'dictOrder',val:'asc'}],
            
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                {
                  title: '模块',
                  dataIndex: 'systemNo'
                },
                {
                  title: '字典名称',
                  dataIndex: 'dictName'
                    
                },
                {
                  title: '字典编号',
                  dataIndex: 'dictCode', 
                },
                
                {
                  title: '操作',
                  dataIndex: 'action',
                  width: '200px',
                  scopedSlots: { customRender: 'action' }
                }
            ],

           

        }
    },
    methods:{
       
    }
    
}
</script>